<template>
	<view class="my-page">
		<u-navbar leftIconColor="#ffffff" :autoBack="true" :placeholder="true" bgColor="rgba(255,255,255,0.0)">
			<view slot="center" class="nav-title">
				抢购记录
			</view>
		</u-navbar>
		<view class="tabs">
			<view :class="current == index?'active-item': 'tabs-item'" class="tabs-item"
				v-for="(item,index) in tabsList" :key="index" @click="cutTab(index)">
				{{item.text}}
			</view>
		</view>
		<view v-if="list.length > 0">
			<view class="item" v-for="(item,index) in list" :key="index">
				<view class="item-top">
					<image :src="item.logo" mode=""></image>
					<view class="item-right">
						<view class="item-title">
							{{item.name}}
						</view>
						<view class="item-cont">
							<view class="info-item">
								<view class="info-text">
									利润(CNY)
								</view>
								<view class="info-num info-title">
									{{item.reward}}
								</view>

							</view>
							<view class="info-item">
								<view class="info-text">
									收益率/日
								</view>
								<view class="info-num">
									{{item.rate}}
								</view>

							</view>
							<view class="info-item">
								<view class="info-text">
									价值
								</view>
								<view class="info-num">
									{{item.price}}
								</view>
							</view>
						</view>
					</view>
				</view>
				<view class="time">
					<view class="time-text" style="text-align: left;">
						<view class="time-left">开始时间：</view>
						<view class="time-right">{{item.create_time}}</view>
					</view>
					<view class="image-right">
						<image src="/static/home/time-right.png" mode=""></image>
					</view>
					<view class="time-text" style="text-align: right;">
						<view class="time-left">结束时间：</view>
						<view class="time-right">{{item.end_time}}</view>
					</view>
				</view>
				<view class="surplus">
					<view class="surplus-btn in-btn" v-if="item.status == 0">
						待抢购
					</view>
					<view class="surplus-btn complete" v-if="item.status == 1" @click="godetails(item.id)">
						上传支付凭证
					</view>
					<view class="surplus-btn in-btn" v-if="item.status == 2" @click="godetails(item.id)">
						等待对方确认
					</view>
					<view class="surplus-btn complete" v-if="item.status == 3">
						交易完成
					</view>
					<view class="surplus-btn appeal" v-if="item.status == 4">
						申诉中
					</view>
					<view class="surplus-btn complete" v-if="item.status == 5">
						申诉成功
					</view>
					<view class="surplus-btn appeal" v-if="item.status == 6">
						申诉失败
					</view>
				</view>
			</view>
			<u-loadmore :status="status" />
		</view>
		<view v-else>
			<u-empty mode="car" icon="../../../static/home/none.png" text="暂无数据" marginTop="100">
			</u-empty>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tabsList: [{
						text: '等待付款'
					},
					{
						text: '正在交易'
					},
					{
						text: '交易完成'
					},
					// {
					// 	text: '交易申诉'
					// }
				],
				current: 0,
				page: 1,
				list: [],
				status: 'loadmore',
			}
		},
		onShow() {
			this.page = 1
			this.getList()
		},
		onReachBottom() {
			this.page++
			this.status = 'loading';
			this.postassets()
		},
		methods: {
			cutTab(index) {
				this.current = index
				this.page = 1
				this.getList()
			},
			godetails(id) {
				uni.navigateTo({
					url: '/pages/my/buy_record/details?id=' + id
				})
			},
			getList() {
				let params = {
					type: this.current + 1,
					page: this.page
				}
				this.$Request({
					method: 'POST',
					url: '/api/trade/adoptList',
					data: params,
					ismsg: false,
				}).then(res => {
					if (res.code == 1) {
						if (res.data.list.length < 10) {
							this.status = 'nomore';
						}
						if (this.page == 1) {
							this.list = res.data.list
						} else {
							this.list = [...this.list, ...res.data.list]
						}
					}
				})
			}
		}
	}
</script>
<style>
	page {
		background: #000000;
	}
</style>
<style lang="scss" scoped>
	.my-page {
		min-height: 100vh;
		padding: 30rpx;

		.nav-title {
			color: #ffffff;
		}

		.tabs {
			display: flex;
			align-items: center;
			justify-content: space-between;
			border-radius: 20rpx;
			border: 1px solid #404040;
			padding: 15rpx;

			.tabs-item {
				width: 33%;
				font-size: 26rpx;
				font-weight: 500;
				color: #8F8F8F;
				text-align: center;
				padding: 15rpx 0;
			}

			.active-item {
				background-color: #FFFFFF;
				border-radius: 10rpx;
				color: #000000;
			}
		}

		.item {
			padding: 30rpx;
			border-radius: 30rpx;
			background: #1A1A1B;
			margin-top: 30rpx;

			.item-top {
				display: flex;
				align-items: center;
				justify-content: space-between;

				image {
					width: 130rpx;
					height: 130rpx;
				}

				.item-right {
					width: 75%;

					.item-title {
						font-size: 34rpx;
						font-weight: bold;
						color: #FFFFFF;
					}

					.item-cont {
						display: flex;
						justify-content: space-between;
						text-align: center;
						margin-top: 20rpx;

						.info-item {
							font-size: 28rpx;

							.info-num {
								color: #ffffff;
								font-weight: bold;
								margin-top: 5rpx;
							}

							.info-text {
								color: #FFFFFF99;
								margin-top: 5rpx;
							}

							.info-title {
								color: #52ECFA;
							}
						}
					}



				}
			}

			.time {
				margin-top: 10rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;

				.image-right {
					image {
						width: 36px;
						height: 8px;
					}
				}

				.time-text {
					width: 40%;
					margin-top: 5rpx;
					font-size: 26rpx;

					.time-left {
						color: #8F8F8F;
					}

					.time-right {
						color: #FFFFFF;
						font-size: 30rpx;
						margin-top: 10rpx;
					}
				}
			}



			.surplus {
				margin-top: 20rpx;
				font-size: 28rpx;
				color: #999999;

				.surplus-btn {
					text-align: center;
					padding: 20rpx 30rpx;
					border-radius: 30rpx;
					font-size: 26rpx;
					color: #fff;
				}

				.in-btn {
					background: linear-gradient(254.51deg, rgba(255, 240, 227, 0.15) 3.64%, rgba(215, 179, 154, 0.15) 86.71%);
					color: #FFD7A2;
				}

				.complete {
					background: linear-gradient(254.51deg, rgba(255, 240, 227, 0.15) 3.64%, rgba(215, 179, 154, 0.15) 86.71%);
					color: #FFD7A2;
				}

				.appeal {
					background: linear-gradient(254.51deg, rgba(255, 240, 227, 0.15) 3.64%, rgba(215, 179, 154, 0.15) 86.71%);
					color: #FFD7A2;
				}
			}
		}
	}
</style>